<template>
  <div>
    <!-- 卡片顶部输入框、查询、添加按钮 -->
    <el-form :inline="true">
      <el-form-item>
        <el-input v-model="requestParameters.username" placeholder="请输入标签码" clearable />
      </el-form-item>
      <el-form-item>
        <el-select v-model="requestParameters.productStatus" placeholder="请选择产品状态" style="width:200px;">
          <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-input v-model="requestParameters.productModel" placeholder="请输入产品型号" clearable />
      </el-form-item>
      <el-form-item>
        <div class="demo-datetime-picker">
          <div class="block">
            <el-date-picker v-model="time" type="datetimerange" start-placeholder="开始日期" end-placeholder="结束日期" format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss" />
          </div>
        </div>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="search" icon="Search">查询</el-button>
        <el-button type="primary" @click="search" icon="Download">下载</el-button>
      </el-form-item>
    </el-form>
    <!-- 表格组件：用于展示用户信息 -->
    <el-table :data="runLogArr" :header-cell-style="{ background: '#6A9BEB', color: '#fff' }">
      <el-table-column label="轴承压装判定区间力最大值" align="center" prop="userName" width="80"></el-table-column>
      <el-table-column label="轴承压装判定区间力最大值处位移值" align="center" prop="userName" width="80"></el-table-column>
      <el-table-column label="轴承压装判定区间力最小值" align="center" prop="date"></el-table-column>
      <el-table-column label="轴承压装判定区间力最小值处位移值" align="center" prop="ip"></el-table-column>
      <el-table-column label="点铆判定区间力最大值" align="center" prop="type"></el-table-column>
      <el-table-column label="点铆判定区间力最大值处位移值" align="center" prop="content"></el-table-column>
      <el-table-column label="点铆判定区间力最小值" align="center" prop="comment" show-overflow-tooltip></el-table-column>
      <el-table-column label="点铆判定区间力最小值处位移值" align="center" prop="comment" show-overflow-tooltip></el-table-column>
      <el-table-column label="过程结果OK/NG判定" align="center" prop="comment" show-overflow-tooltip></el-table-column>
      <el-table-column label="轴承压装判定区间力最大值" align="center" prop="comment" show-overflow-tooltip></el-table-column>
			<el-table-column label="轴承压装判定区间力最大值处位移值" align="center" prop="comment" show-overflow-tooltip></el-table-column>
			<el-table-column label="轴承压装判定区间力最小值" align="center" prop="comment" show-overflow-tooltip></el-table-column>
			<el-table-column label="轴承压装判定区间力最小值处位移值" align="center" prop="comment" show-overflow-tooltip></el-table-column>
			<el-table-column label="点铆判定区间力最大值" align="center" prop="comment" show-overflow-tooltip></el-table-column>
			<el-table-column label="点铆判定区间力最大值处位移值" align="center" prop="comment" show-overflow-tooltip></el-table-column>
			<el-table-column label="点铆判定区间力最小值" align="center" prop="comment" show-overflow-tooltip></el-table-column>
			<el-table-column label="点铆判定区间力最小值处位移值" align="center" prop="comment" show-overflow-tooltip></el-table-column>
			<el-table-column label="过程结果OK/NG判定" align="center" prop="comment" show-overflow-tooltip></el-table-column>
			<el-table-column label="外节叉批次号" align="center" prop="comment" show-overflow-tooltip></el-table-column>
			<el-table-column label="轴承批次号" align="center" prop="comment" show-overflow-tooltip></el-table-column>
			<el-table-column label="十字轴批次号" align="center" prop="comment" show-overflow-tooltip></el-table-column>
    </el-table>
    <!-- 分页器组件 -->
    <el-pagination @size-change="sizeChange" @current-change="getOperateInfo" v-model:current-page="requestParameters.pageNum" v-model:page-size="requestParameters.pageSize" :page-sizes="[10, 20, 50, 100]" :background="true" layout="prev,pager,next,jumper,->,sizes,total" :total="total" />
  </div>
</template>
<script setup lang="ts">
import { ref, onMounted, reactive } from 'vue';
//存储时间
let time = ref<any>([]);
//产品状态的选择项
const options = [
  {
    value: 'Option1',
    label: 'OK',
  },
  {
    value: 'Option2',
    label: 'NG',
  },
];
//请求全部操作日志参数
let requestParameters = reactive<any>({
  username: '', //用户名
	productStatus:'',//产品状态
	productModel:'',//产品型号
  beginTime: '', //开始时间
  endingTime: '', //结束时间
  pageNum: 1, //当前页码
  pageSize: 10, // //每一页展示多少条数据
});
//存储已有运行日志数据总数
let total = ref<number>(0);
//存储已有操作日志的数据(Records定义了一个数组，右边括号里面的[]为初始化数组)
let runLogArr = ref<any>([]);
//组件挂载完毕，发请求获取全部的运行日志
onMounted(() => {
  getOperateInfo();
});
const getOperateInfo = async (pager = 1) => {
  requestParameters.pageNum = pager;

  // let result: any = await reqOperate(requestParameters);
  // if (result.code === 200) {
  //   total.value = result.data.total; //存储已有运行日志总个数
  //   runLogArr.value = result.data.records; //存储已有运行日志数据
  // }
};
//当下拉菜单发生变化的时候触发此方法
const sizeChange = () => {
  getOperateInfo();
};
//查询用户
const search = () => {
  requestParameters.beginTime = time.value[0];
  requestParameters.endingTime = time.value[1];
  //根据关键字获取相应的数据
  getOperateInfo();
  //清空数据
  requestParameters.username = '';
  time.value = '';
};
</script>
<style scoped>
.demo-datetime-picker {
  display: flex;
  width: 100%;
  padding: 0;
  flex-wrap: wrap;
  justify-content: space-around;
  align-items: stretch;
}

.demo-datetime-picker .block {
  text-align: center;
}

.line {
  width: 1px;
  background-color: var(--el-border-color);
}
</style>
